﻿/*
* ============================================================================
* GNU Lesser General Public License
* ============================================================================
*
* BYDAN - Free Java BYDAN library.
* Copyright (C) 2008 
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
* 
* BYDAN Corporation
*/
package ByDan.AulaVirtual.Business.Entities;

import java.util.ArrayList;
import ByDan.Framework.AulaVirtual.Business.Entities.GeneralEntity;
import ByDan.Framework.AulaVirtual.Business.Entities.Mensajes;
import ByDan.Framework.AulaVirtual.Utils.ParameterDbType;
import ByDan.Framework.AulaVirtual.Utils.ParameterType;
import ByDan.Framework.AulaVirtual.Utils.ParametersMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterValue;
import ByDan.Framework.AulaVirtual.Utils.ParametersType;
import java.sql.*;

public class UnidadCurricular extends GeneralEntity
{
	static  String strTableName="UnidadCurricular";
		
	public static String getStrTableName() 
	{
		return strTableName;
	}

	public static void setStrTableName(String strTableName) 
	{
		UnidadCurricular.strTableName = strTableName;
	}
	
	public static String getColumnNameId()
	{
		return "id";
	}
	
	public UnidadCurricular unidadcurricularOriginal;
	
	public UnidadCurricular getUnidadCurricularOriginal()
	{
		return unidadcurricularOriginal;
	}
	
	public  void  setUnidadCurricularOriginal(UnidadCurricular unidadcurricular)
	{
		try
		{
			unidadcurricularOriginal=unidadcurricular;
		}
		catch(Exception ex)
		{
			;
		}
	}
	
	
	
	
	Curso relationship_curso;
	 
	
	public Curso getRelationship_Curso()
	{
		return relationship_curso;
	}

	
	
	public  void  setRelationship_Curso(Curso curso)
	{
		try
		{
			relationship_curso=curso;
		}
		catch(Exception ex)
		{
			;
		}
	}


	
	
	ArrayList<UnidadCurricularTutor> relationship_unidadcurriculartutors;
	ArrayList<TipoTest> relationship_tipotests;
	ArrayList<Test> relationship_tests;
	ArrayList<Tutor> relationship_tutors;
	ArrayList<Pagina> relationship_paginas;
	ArrayList<Tutoria> relationship_tutorias;
	
	
	public ArrayList<UnidadCurricularTutor> getRelationship_unidadcurriculartutors()
	{
		return relationship_unidadcurriculartutors;
	}

	public ArrayList<TipoTest> getRelationship_tipotests()
	{
		return relationship_tipotests;
	}

	public ArrayList<Test> getRelationship_tests()
	{
		return relationship_tests;
	}

	public ArrayList<Tutor> getRelationship_tutors()
	{
		return relationship_tutors;
	}

	public ArrayList<Pagina> getRelationship_paginas()
	{
		return relationship_paginas;
	}

	public ArrayList<Tutoria> getRelationship_tutorias()
	{
		return relationship_tutorias;
	}

	
	
	public  void  setRelationship_UnidadCurricularTutor(ArrayList<UnidadCurricularTutor> unidadcurriculartutors)
	{
		try
		{
			this.relationship_unidadcurriculartutors=unidadcurriculartutors;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_TipoTest(ArrayList<TipoTest> tipotests)
	{
		try
		{
			this.relationship_tipotests=tipotests;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_Test(ArrayList<Test> tests)
	{
		try
		{
			this.relationship_tests=tests;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_Tutor(ArrayList<Tutor> tutors)
	{
		try
		{
			this.relationship_tutors=tutors;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_Pagina(ArrayList<Pagina> paginas)
	{
		try
		{
			this.relationship_paginas=paginas;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_Tutoria(ArrayList<Tutoria> tutorias)
	{
		try
		{
			this.relationship_tutorias=tutorias;
		}
		catch(Exception ex)
		{
			;
		}
	}

	
	private static Boolean blnDeleteCascade=false;
	private static String QueryInsert="insert into aulavirtualme_dbo.UnidadCurricular set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDCURSO=?,CODIGO=?,NOMBRE=?,EVALUACION=?,ESTADO=?,HORAS=?,OBJETIVOS=?,OBSERVACIONES=?";
	private static String QueryUpdate="update aulavirtualme_dbo.UnidadCurricular set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDCURSO=?,CODIGO=?,NOMBRE=?,EVALUACION=?,ESTADO=?,HORAS=?,OBJETIVOS=?,OBSERVACIONES=? where id=? AND versionRow=?";
	private static String QueryDelete="delete from aulavirtualme_dbo.UnidadCurricular where id=?";
	public static String QuerySelect="select aulavirtualme_dbo.UnidadCurricular.id,aulavirtualme_dbo.UnidadCurricular.isActive,aulavirtualme_dbo.UnidadCurricular.isExpired,aulavirtualme_dbo.UnidadCurricular.versionRow,aulavirtualme_dbo.UnidadCurricular.IDCURSO,aulavirtualme_dbo.UnidadCurricular.CODIGO,aulavirtualme_dbo.UnidadCurricular.NOMBRE,aulavirtualme_dbo.UnidadCurricular.EVALUACION,aulavirtualme_dbo.UnidadCurricular.ESTADO,aulavirtualme_dbo.UnidadCurricular.HORAS,aulavirtualme_dbo.UnidadCurricular.OBJETIVOS,aulavirtualme_dbo.UnidadCurricular.OBSERVACIONES from aulavirtualme_dbo.UnidadCurricular";
	 
	Long field_bigIdCurso;
	String field_strCodigo;
	String field_strNombre;
	Double field_decEvaluacion;
	Boolean field_bitEstado;
	Integer field_intHoras;
	String field_strObjetivos;
	String field_strObservaciones;
				
	public UnidadCurricular ()
    {
		super();		
 		field_bigIdCurso=-1L;
 		field_strCodigo="";
 		field_strNombre="";
 		field_decEvaluacion=null;
 		field_bitEstado=false;
 		field_intHoras=null;
 		field_strObjetivos=null;
 		field_strObservaciones=null;
		
		
		relationship_curso=new Curso();
		
		
		relationship_unidadcurriculartutors=new ArrayList<UnidadCurricularTutor>();
		relationship_tipotests=new ArrayList<TipoTest>();
		relationship_tests=new ArrayList<Test>();
		relationship_tutors=new ArrayList<Tutor>();
		relationship_paginas=new ArrayList<Pagina>();
		relationship_tutorias=new ArrayList<Tutoria>();
		
		super.setQueryInsert(QueryInsert);
		super.setQueryUpdate(QueryUpdate);
		super.setQueryDelete(QueryDelete);
		super.setQuerySelect(QuerySelect);
		
    } 
	
	public static Boolean getBlnDeleteCascade() 
	{
		return blnDeleteCascade;
	}

	public static void setBlnDeleteCascade(Boolean blnDeleteCascade) 
	{
		UnidadCurricular.blnDeleteCascade = blnDeleteCascade;
	}
	
	public static String getTableName()
    {
         return "aulavirtualme_dbo.UnidadCurricular";
    }
	
    
	public static String getColumnNameidCurso()
	{
		return "idCurso";
	}
    
	public static String getColumnNameCodigo()
	{
		return "Codigo";
	}
    
	public static String getColumnNameNombre()
	{
		return "Nombre";
	}
    
	public static String getColumnNameEvaluacion()
	{
		return "Evaluacion";
	}
    
	public static String getColumnNameEstado()
	{
		return "Estado";
	}
    
	public static String getColumnNameHoras()
	{
		return "Horas";
	}
    
	public static String getColumnNameObjetivos()
	{
		return "Objetivos";
	}
    
	public static String getColumnNameObservaciones()
	{
		return "Observaciones";
	}
     
    
	public Long getField_bigIdCurso()
	{
		return field_bigIdCurso;
	}
    
	public String getField_strCodigo()
	{
		return field_strCodigo;
	}
    
	public String getField_strNombre()
	{
		return field_strNombre;
	}
    
	public Double getField_decEvaluacion()
	{
		return field_decEvaluacion;
	}
    
	public Boolean getField_bitEstado()
	{
		return field_bitEstado;
	}
    
	public Integer getField_intHoras()
	{
		return field_intHoras;
	}
    
	public String getField_strObjetivos()
	{
		return field_strObjetivos;
	}
    
	public String getField_strObservaciones()
	{
		return field_strObservaciones;
	}
	
    
	public void setField_bigIdCurso(Long newField_bigIdCurso)throws Exception
	{
		try
		{
			if(this.field_bigIdCurso!=newField_bigIdCurso)
			{
				if(newField_bigIdCurso==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+UnidadCurricular.getColumnNameidCurso());
				}

				this.field_bigIdCurso=newField_bigIdCurso;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strCodigo(String newField_strCodigo)throws Exception
	{
		try
		{
			if(this.field_strCodigo!=newField_strCodigo)
			{
				if(newField_strCodigo==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+UnidadCurricular.getColumnNameCodigo());
				}

				this.field_strCodigo=newField_strCodigo;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strNombre(String newField_strNombre)throws Exception
	{
		try
		{
			if(this.field_strNombre!=newField_strNombre)
			{
				if(newField_strNombre==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+UnidadCurricular.getColumnNameNombre());
				}

				this.field_strNombre=newField_strNombre;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_decEvaluacion(Double newField_decEvaluacion)
	{
		if(this.field_decEvaluacion!=newField_decEvaluacion)
		{
			this.field_decEvaluacion=newField_decEvaluacion;
			this.setIsChanged(true);
		}
	}
    
	public void setField_bitEstado(Boolean newField_bitEstado)throws Exception
	{
		try
		{
			if(this.field_bitEstado!=newField_bitEstado)
			{
				if(newField_bitEstado==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+UnidadCurricular.getColumnNameEstado());
				}

				this.field_bitEstado=newField_bitEstado;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_intHoras(Integer newField_intHoras)
	{
		if(this.field_intHoras!=newField_intHoras)
		{
			this.field_intHoras=newField_intHoras;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strObjetivos(String newField_strObjetivos)
	{
		if(this.field_strObjetivos!=newField_strObjetivos)
		{
			this.field_strObjetivos=newField_strObjetivos;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strObservaciones(String newField_strObservaciones)
	{
		if(this.field_strObservaciones!=newField_strObservaciones)
		{
			this.field_strObservaciones=newField_strObservaciones;
			this.setIsChanged(true);
		}
	}
		
	public  void BuildParametersMaintenance(ParameterDbType newDbType,ParametersType parametersType) throws Exception
	{
		try
		{
			ParametersMaintenance parametersMaintenance=super.getParametersMaintenance();		
			ArrayList<ParameterMaintenance> parametersTemp=new ArrayList<ParameterMaintenance>();
			ParameterMaintenance parameterMaintenance;
			ParameterValue<Long> parameterMaintenanceValueId;
			
				if(!parametersType.equals(ParametersType.DELETE))
				{		
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsactive=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsactive.setValue(this.getIsActive());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsactive);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(2);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsexpired=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsexpired.setValue(this.getIsExpired());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsexpired);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(3);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdCurso=new ParameterValue<Long>();
					parameterMaintenanceValueIdCurso.setValue(this.getField_bigIdCurso());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdCurso);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(4);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueCodigo=new ParameterValue<String>();
					parameterMaintenanceValueCodigo.setValue(this.getField_strCodigo());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueCodigo);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(5);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueNombre=new ParameterValue<String>();
					parameterMaintenanceValueNombre.setValue(this.getField_strNombre());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueNombre);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(6);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.DOUBLE);
					ParameterValue<Double> parameterMaintenanceValueEvaluacion=new ParameterValue<Double>();
					parameterMaintenanceValueEvaluacion.setValue(this.getField_decEvaluacion());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueEvaluacion);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(7);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueEstado=new ParameterValue<Boolean>();
					parameterMaintenanceValueEstado.setValue(this.getField_bitEstado());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueEstado);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(8);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.INT);
					ParameterValue<Integer> parameterMaintenanceValueHoras=new ParameterValue<Integer>();
					parameterMaintenanceValueHoras.setValue(this.getField_intHoras());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueHoras);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(9);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueObjetivos=new ParameterValue<String>();
					parameterMaintenanceValueObjetivos.setValue(this.getField_strObjetivos());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueObjetivos);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(10);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueObservaciones=new ParameterValue<String>();
					parameterMaintenanceValueObservaciones.setValue(this.getField_strObservaciones());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueObservaciones);
					parametersTemp.add(parameterMaintenance);
					
						if(parametersType.equals(ParametersType.UPDATE))
						{					
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(11);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
							parameterMaintenanceValueId=new ParameterValue<Long>();
							parameterMaintenanceValueId.setValue(this.getId());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
							parametersTemp.add(parameterMaintenance);
							
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(12);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.TIMESTAMP);
							ParameterValue<Timestamp> parameterMaintenanceValueVersionRow=new ParameterValue<Timestamp>();
							parameterMaintenanceValueVersionRow.setValue(this.getVersionRow());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueVersionRow);		
							parametersTemp.add(parameterMaintenance);					
						}
				}
				else
				{
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					parameterMaintenanceValueId=new ParameterValue<Long>();
					parameterMaintenanceValueId.setValue(this.getId());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
					parametersTemp.add(parameterMaintenance);
				}
			
			parametersMaintenance= new ParametersMaintenance();
			parametersMaintenance.setDbType(newDbType);
			parametersMaintenance.setParametersMaintenance(parametersTemp);
			super.setParametersMaintenance(parametersMaintenance);		
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
}
